name: OpenVINO - Notebooks Test

on:
  workflow_dispatch:
  schedule:
    - cron:  '14 3 * * 1'  # run weekly: every Monday at 3:14
  push:
    paths:
    - '.github/workflows/test_openvino_notebooks.yml'
    - 'notebooks/openvino/*'
  pull_request:
    paths:
    - '.github/workflows/test_openvino_notebooks.yml'
    - 'notebooks/openvino/*'


concurrency:
  group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
  cancel-in-progress: true

jobs:
  build:
    strategy:
      fail-fast: false
      matrix:
        python-version: ["3.8", "3.10"]

    runs-on: ubuntu-20.04

    steps:
    - uses: actions/checkout@v2
    - name: Setup Python ${{ matrix.python-version }}
      uses: actions/setup-python@v2
      with:
        python-version: ${{ matrix.python-version }}

    - name: Install dependencies
      run: |
        # Install PyTorch CPU to prevent unnecessary downloading/installing of CUDA packages
        # ffmpeg, torchaudio and pillow are required for image classification and audio classification pipelines
        sudo apt-get install ffmpeg
        pip install torch torchaudio --extra-index-url https://download.pytorch.org/whl/cpu
        pip install ".[tests, openvino]" nbval
        pip install -r notebooks/openvino/requirements.txt

    - run: free -h
    - run: lscpu
    - run: pip freeze

    - name: Test with Pytest
      run: |
        python -m pytest --nbval-lax notebooks/openvino/optimum_openvino_inference.ipynb  notebooks/openvino/question_answering_quantization.ipynb

